var targetNum1 = document.querySelector(".location-text>.text-number");
var targetNum2 = document.querySelector(".warning-text>.text-number");
var getImg = document.querySelector(".getImg");
var bottomTitle = document.querySelector(".bottomTitle");
var place = document.querySelector(".place");
var getTime = document.querySelector(".getTime");
var tbody = document.querySelector("tbody");
var datas = [];
let startEm = 0

function ajax8() {
  $.ajax({
    url: "/large-screen/black/selectBlackCount",
    type: "GET",
    crossDomain: true,
    dataType: "json",
    async: false,
    success: function (res) {
      targetNum1.innerText = res.data;
    },
    error: function (xhr, status) {
      console.log(status);
    },
  });

  $.ajax({
    url: "/large-screen/black/selectBlackWarning",
    type: "GET",
    crossDomain: true,
    dataType: "json",
    async: false,
    success: function (res) {
      // console.log(res);
      tbody.innerHTML = "";
      targetNum2.innerText = res.data.count;
      getImg.setAttribute("src", res.data.blackDetail[startEm].picUrl);
      bottomTitle.innerText = "黑名单：" + res.data.blackDetail[startEm].name;
      place.innerText = res.data.blackDetail[startEm].address;
      getTime.innerText = res.data.blackDetail[startEm].time.substring(11);
      timeInterval = setInterval(() => {
        startEm++
        if (startEm === res.data.blackDetail.length) {
          startEm = 0
        }
        getImg.setAttribute("src", res.data.blackDetail[startEm].picUrl);
        bottomTitle.innerText = "黑名单：" + res.data.blackDetail[startEm].name;
        place.innerText = res.data.blackDetail[startEm].address;
        getTime.innerText = res.data.blackDetail[startEm].time.substring(11);
      }, 3000);
      // 重点关注弹窗表格
      datas = JSON.parse(JSON.stringify(res.data.blackDetail));
      for (let i = 0; i < datas.length; i++) {
        var tr = document.createElement("tr");
        tbody.appendChild(tr);
        delete datas[i].picUrl;
        delete datas[i].faceInfoIndexCode;
        for (let k in datas[i]) {
          var td = document.createElement("td");
          td.innerHTML = datas[i][k];
          tr.appendChild(td);
        }
      }
    },
    error: function (xhr, status) {
      console.log(status);
    },
  });
}



setInterval(() => {
  startEm = 0
  clearInterval(timeInterval)
  ajax8();
}, 3600000);
